package com.hz.ruoyistorage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hz.ruoyistorage.domain.LgSubCold;
import com.hz.ruoyistorage.domain.mypojo.ColdType;
import com.hz.ruoyistorage.domain.mypojo.LgSubColdSome;
import com.hz.ruoyistorage.mapper.LgSubColdMapper;
import com.hz.ruoyistorage.service.LgSubColdService;
import com.hz.ruoyistorage.utils.ResultJSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Author gj
 * @Date 2025/3/6 9:58
 * @注释
 */
@Service
public class LgSubColdServiceImpl
        extends ServiceImpl<LgSubColdMapper, LgSubCold>
        implements LgSubColdService {
    @Autowired
    private LgSubColdMapper lgSubColdMapper;

    @Override
    public List<ColdType> getColdType() {
        return lgSubColdMapper.getColdType();
    }

    @Override
    public String getPriceMeter(Integer coldTypeId) {
        return lgSubColdMapper.getPriceMeter(coldTypeId);
    }

    @Override
    public LgSubCold selectById(Integer subId) {
        return lgSubColdMapper.selectById(subId);
    }

    //重新计算单日价格
    @Override
    public boolean updateDailyPrice(LgSubCold lgSubCold) {
        //算钱
        //获得容积
        Double firstNum = lgSubCold.getCapacity();
        //获得单价
        Integer aaa = lgSubCold.getColdId();
        Double secondNum = Double.valueOf(lgSubColdMapper.getPriceMeter(aaa));
        lgSubCold.setDailyPrice(firstNum*secondNum);
        return true;
    }

    @Override
    public List<LgSubColdSome> getIdAndName() {
        return lgSubColdMapper.getIdAndName();
    }

    @Override
    public List<Map<String, Object>> getSubColdSome() {
        return lgSubColdMapper.getSubColdSome();
    }
}
